﻿@model MemberPoint.Entity.ViewModel.GiftSViewModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>礼品管理</title>
    <link href="~/Content/Easy UI/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/Easy UI/themes/icon.css" rel="stylesheet" />@*图片*@
    <script src="~/Content/Easy UI/script/jquery-1.11.1.js"></script>
    <script src="~/Content/Easy UI/script/jquery.easyui.min.js"></script>
    <script src="~/Content/Easy UI/script/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#dg").datagrid({
                fitColumns: false,//使列自动展开，收缩到合适的Datagrid高度
                toolbar: "#tb",//toolbar:通过选择器指定的工具栏
                pagination: true,//自动生成分页工具  pagination：如果为true，则在Datagrid控件底部显示分页工具栏
                /* fit: true,*///当设置为true的时候面板大小将自适应父容器
                singleSelect: true,//如果为true则只能选择一行
                rownumbers: true,//如果为true则显示一个行号列
                url: "/Gifts/GetGiftss",//设置能够返回Json数据的Action所对应的路径
                columns: [[
                    { field: 'EG_ID', title: '礼品编号', width: 130, align: "center", },
                    { field: 'EG_GiftCode', title: '礼品代号', width: 130, align: "center", },
                    { field: 'EG_GiftName', title: '礼品名称', width: 130, align: "center", },
                    { field: 'EG_Point', title: '所需积分', width: 130, align: "center", },
                    { field: 'EG_Number', title: '礼品数量', width: 150, align: "center", },
                    { field: 'EG_ExchangNum', title: '已兑换数量', width: 270, align: "center", },
                    { field: 'EG_Remark', title: '备注', width: 170, align: "center", }
                ]]
            })
            //添加礼品
            $(".insert").click(function () {
                $("#dlg").dialog({ width: 800, height: 800 }).dialog("setTitle", "新增").dialog("open");
                $("#frm1").attr("src", "/Gifts/GiftsInsert");
            })
            //修改礼品
            $(".Up").click(function () {
                var row = $("#dg").datagrid("getSelected");
                if (row != null) {
                    $("#dlg").dialog({ width: 800, height: 800 }).dialog("setTitle", "修改").dialog("open");
                    $("#frm1").attr("src", "/Gifts/GiftsUpdate/" + row.EG_ID);
                }
                else
                {
                    $.messager.alert("提示","请选择要修改的行","warning")
                }
            })
            //删除
            $(".Delete").click(function () {
                var row = $("#dg").datagrid("getSelected");
                if (row != null) {
                    $.post("/Gifts/Delete", { EG_ID: row.EG_ID }, function (data) {
                        if (data.ResultStatus == 1) {
                            $.messager.alert("提示", data.Msg, "info");
                            $("#dg").datagrid("reload");
                        } else {
                            $.messager.alert("提示", data.Msg, "warning");
                        }
                    })

                } else {
                    $.messager.alert("提示", data.Msg, "warning");
                }
            })
        })
    </script>
</head>
<body>
    <div>
        <div id="tb">
            <a id="btn" href="javascript:" class="easyui-linkbutton insert" data-options="iconCls:'icon-add'">新增</a>
            <a id="btn" href="javascript:" class="easyui-linkbutton Up" data-options="iconCls:'icon-edit'">修改</a>
            <a id="btn" href="javascript:" class="easyui-linkbutton Delete" data-options="iconCls:'icon-remove'">删除</a>
            <br />


        </div>
        <table class="easyui-datagrid" id="dg"></table>
        <div id="dlg" class="easyui-dialog" data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true">
            <iframe id="frm1" width="99%" height="99%" frameborder="0"></iframe>
        </div>
    </div>
</body>
</html>
